USE [Training]
GO

IF NOT EXISTS (SELECT * from dbo.sysobjects WHERE id = OBJECT_ID(N'dbo.training_api_DepartmentTreeUpdate'))
	EXEC('CREATE PROC dbo.training_api_DepartmentTreeUpdate AS')
GO

ALTER PROC dbo.training_api_DepartmentTreeUpdate
	@LocationID			int,
	@Parent				int = null,
	@Child				int = null,
	@DepartmentTreeID	int 
AS
	UPDATE DepartmentTree
	SET
		LocationID = @LocationID,
		Parent = @Parent,
		Child = @Child
	WHERE
		DepartmentTreeID = @DepartmentTreeID
